<div id="sidetabs_body_container">
<?php if(validation_errors() || @$error || @$zero):?>
    <div id="error_container" style='display:block'>
        <div class="notice_explanation_container">
            <div class="notice_explanation bad">
                <strong>Oh lỗi!</strong>&nbsp;&nbsp;<?php echo validation_errors(); ?>
                <?php if(@$error):?>
                <br />
                <?php echo $error?>
                <?php endif;?>
            </div>
        </div>
    </div>
<?php endif;?>
    
    <div class="main_container">
        <div id="detail_header">
          <table class="lean">
            <tbody><tr>
              <td style="padding:5px 10px 0 0" colspan="2"><a href="<?php echo $baseurl?>group" id="list_link">Quản lý nhóm mạng</a>&nbsp;›
              </td>
              <td>
                <h1 class="db s3name">Danh sách nhóm mạng</h1>
              </td>
            </tr>
          </tbody></table>
        
          <hr style="clear:both" class="s3"/>
        </div>
        <div id="detail_area">
            <div class="hideport3" id="details_wrapper">
                <div class="left-pos">
                    <?php $attr = array('class' => 'form-target'); echo form_open('', $attr);?>
                    <table class="s3basicedit wiform">
                       <tbody>
                          <tr>
                             <td colspan="2">
                                <h2 class="s3">Thêm nhóm mạng</h2>
                                <hr style="margin-top: -2px" class="s3"/>
                             </td>
                          </tr>
                          <tr class="base">
                            <input type="hidden" name="id" value="0"/>
                            <input type="hidden" name="type" value="add"/>
                          </tr>
                          <tr class="top">
                             <td class="s3l align-right">Tên nhóm mạng:</td>
                             <td class="s3w"><input type="text" value="<?php echo $this->input->post('name')?>" name="name" id="name" class="w99"/></td>
                          </tr>
                          <tr class="top">
                             <td class="s3l align-right">Ghi chú:</td>
                             <td class="s3w"><textarea rows="3" name="notes" id="notes"><?php echo $this->input->post('notes')?></textarea></td>
                          </tr>
                          <tr class="base">
                             <td colspan="2" class="s3actions">
                                <div>
                                   <table style="margin: 0.5ex auto 0.5ex auto" class="lean">
                                      <tbody>
                                         <tr>
                                            <td><input type="submit" id="submit" value="Save"/> <input type="reset" value="Cancel"/></td>
                                         </tr>
                                      </tbody>
                                   </table>
                                </div>
                             </td>
                          </tr>
                       </tbody>
                    </table>
                    </form>
                </div>
                <div class="right-pos">
                    <div style="position:relative" id="client_table" class="flex-table add_col">
                       <table class="filter compact fill">
                       <colgroup>
                             <col>
                             <col width="0*">
                             <col>
                             <col>
                             <col>
                             <col>
                             <col>
                             <col>
                          </colgroup>
                          <thead>
                             <tr class="ft_head">
                                <th class="ft ftl checkbox nodrag checknum checkbox ftlegend" style="width:40px"><input type="checkbox" class="check_all"/></th>
                                <th class="ft ftl undefined nodrag name ftsortable">
                                   <table class="lean">
                                      <tbody>
                                         <tr style="vertical-align:bottom">
                                            <td class="ftlegend">Nhóm mạng</td>
                                            <td style="padding:0 5px"></td>
                                         </tr>
                                      </tbody>
                                   </table>
                                </th>
                                <th class="ft ftl action ftsortable">
                                   <table class="lean">
                                      <tbody>
                                         <tr style="vertical-align:bottom">
                                            <td class="ftlegend">Tác vụ</td>
                                            <td style="padding:0 5px"></td>
                                         </tr>
                                      </tbody>
                                   </table>
                                </th>
                             </tr>
                          </thead>
                          <tfoot>
                             <tr class="ft_foot">
                                <td colspan="4" class="ft_foot">
                                   <table class="ft_foot">
                                      <tfoot>
                                         <tr class="ft_foot">
                                            <td class="pgnum">
                                                <?php echo $this->pagination->create_links();?>
                                            </td>
                                         </tr>
                                      </tfoot>
                                   </table>
                                </td>
                             </tr>
                          </tfoot>
                          <tbody>
                            <?php
                                if($page_current != 0){
                            	   $page_current = $page_current - 1;
                            	}
                                 
                                $i = 1;
                                foreach($data AS $key => $value):?>
                            <?php
                            
                                $stt = $page_current * $_per_page + $i;

                                $ss = $stt % 2;
                                if ($ss == 0){
                                    $class = 'ftp1';
                                }else{
                                    $class = 'ftp0';
                                }
                            ?>
                            <tr data-idx="<?php echo $stt?>" class="<?php echo $class?>">
                                <td class="ft checkbox nodrag checknum"><input type="checkbox" class="row_check"/>&nbsp;<?php echo $stt?></td>
                                <td class="ft undefined nodrag"><?php echo $value->name?></td>
                                <td class="ft undefined nodrag">
                                    <a data-id="<?php echo $value->id?>" class="editaj" href="#">Sửa</a> | <a class="deleteaj" href="<?php echo $baseurl?>delete-group?id=<?php echo $value->id?>">Xóa</a>
                                </td>
                             </tr>
                            <?php $i++; endforeach;?>
                          </tbody>
                       </table>
                    </div>
                </div>
            </div>
        </div>

    </div>

</div>


<script type="text/javascript">
    $(document).ready(function(){
        $(document).on('click' , '.editaj', function(){
            var id = $(this).data('id');
            
            $.ajax({
                type: "GET",
                url: baseUrl + 'group-detail',
                data: ({id: id}),
                success: function(data){
                    $('.form-target').html(data);
                }
            });
            
            return false;
        });
        $(document).on('click' , '.cancelaj', function(){
            var html = '<table class="s3basicedit wiform"> <tbody> <tr> <td colspan="2"> <h2 class="s3">Thêm nhóm mạng</h2> <hr style="margin-top: -2px" class="s3"/> </td></tr><tr class="base"> <input type="hidden" name="id" value="0"/> <input type="hidden" name="type" value="add"/> </tr><tr class="top"> <td class="s3l align-right">Tên nhóm mạng:</td><td class="s3w"><input type="text" value="" name="name" id="name" class="w99"/></td></tr><tr class="top"> <td class="s3l align-right">Ghi chú:</td><td class="s3w"><textarea rows="3" name="notes" id="notes"></textarea></td></tr><tr class="base"> <td colspan="2" class="s3actions"> <div> <table style="margin: 0.5ex auto 0.5ex auto" class="lean"> <tbody> <tr> <td><input type="submit" id="submit" value="Save"/> <input type="reset" value="Cancel"/></td></tr></tbody> </table> </div></td></tr></tbody> </table>';
            $('.form-target').html(html);
            
            return false;
        });
        
        $(document).on('click' , '.deleteaj', function(){
            var f = confirm("Bạn muốn xóa nhóm mạng này");
            if(f){
                return true;
            }else{
                return false;
            }
        });
    });
</script>